<?php require_once('Connections/mysql_admin.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['admin_user'])) {
  $loginUsername=$_POST['admin_user'];
  $password=$_POST['admin_pass'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "painel_admin.php";
  $MM_redirectLoginFailed = "login_admin_erro.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_mysql_admin, $mysql_admin);
  
  $LoginRS__query=sprintf("SELECT usuario_admin, password_admin FROM dados_admin WHERE usuario_admin=%s AND password_admin=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $mysql_admin) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LSecurity</title>
<style type="text/css">
<!--
body {
	background-color: #3399FF;
}
-->
</style>
<style type="text/css">
<!--
.style2 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
}
-->
</style>
<style type="text/css">
<!--
.style11 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style13 {font-size: 12px}
-->
</style>
<script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style14 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; }
-->
</style>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div align="center">
  <p><img src="index.gif" width="400" height="150" /></p>
</div>
<table width="869" height="112" border="0" align="center">
  <tr>
    <td width="870"><table width="870" border="0" align="center">
      <tr>
        <td><div id="CollapsiblePanel2" class="CollapsiblePanel">
          <div class="CollapsiblePanelContent"><span id="sprytextfield2">
              <label> </label>
              </span>
            <label> </label>
            <div id="CollapsiblePanel1" class="CollapsiblePanel">
              <div class="CollapsiblePanelTab" tabindex="0">
                <div align="center">Log-In no Painel de Admin</div>
              </div>
              <div class="CollapsiblePanelContent">
                <div align="center" class="style11">
                  <p>&nbsp;                    </p>
                  <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
                    <label><span class="style13">Usuário: <br />
                    <br />
                    <span id="sprytextfield1">
                    <input type="text" name="admin_user" id="admin_user" />
                    <span class="textfieldRequiredMsg">Campo Necessário!</span></span></span></label>
                    <span class="style13"><br />
                    <br />
                    Password:<br />
                    <br />
                    <span id="sprytextfield5">
                    <label>
                    <input type="password" name="admin_pass" id="admin_pass" />
                    </label>
                    <span class="textfieldRequiredMsg">Campo Necessário!</span></span></span>
                    <label> </label>
                    <br />
<label> <br />
<input type="submit" name="entrar_admin" id="entrar_admin" value="Entrar" />
                    </label></form>
                  <p>
                    <label></label>
                    <br />
                    </p>
                </div>
              </div>
            </div>
            <span class="style2">
<label> </label>
                </span></div>
        </div>
            <p align="center" class="style14">Feito por Deluxor 2007</p>          </td>
      </tr>
    </table></td>
  </tr>
</table>
<table width="870" border="0" align="center">
  <tr></tr>
</table>
<script type="text/javascript">
<!--
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4");
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5");
//-->
</script>
</body>
</html>
